#include <iostream>
#include <vector>

using namespace std;

const int N = 1e5 + 10;

int n, q;
vector<int> a[N];

int main()
{
	cin >> n >> q;
	while(q--)
	{
		int x, i, j, k; 
		cin >> x >> i >> j;
		if(x == 1) 
		{
			//存
			cin >> k;
			if(j >= a[i].size())
			{
				a[i].resize(j + 1);
			}
			a[i][j] = k;
		}
		else 
		{
			//取
			cout << a[i][j] << endl;
		}
	}

	return 0;
}